package lew.bing.novels;

import java.util.List;

/**
 * Created by 刘国兵 on 2019/8/18.
 *
 * @author 刘国兵
 */
public abstract class AbstractNovelLoader implements NovelLoader {

    protected List<String> addresses;


    protected abstract Novel getFromAddress(String address) ;

    @Override
    public Novel getNovel(int idx) {
        if (this.addresses == null) {
            this.addresses = addresses();
        }
        Novel address = getFromAddress(addresses.get(idx));
        if (address != null) {
            address.setIdx(idx);
        }
        return address;
    }
}
